from tkinter import*
root = Tk()
w = Canvas(root,width=200,height=100)
w.pack()
#画线
line1 =  w.create_line(0,50,200,50,fill="yellow")
line2 = w.create_line(100,0,100,100,fill="red",dash=(4,4))
rect1 = w.create_rectangle(50,25,150,75,fill="blue")
#写文本
w.create_text(100,50,text="FishC")
#移动到一个新的位置
w.coords(line1,0,25,200,25)
#设置配置
w.itemconfig(rect1,fill="red")
#删除
w.delete(line2)
#创建删除按钮
Button(root,text="删除全部",command=(lambda x="all": w.delete(x))).pack()
mainloop()